package com.hxkj.controller;

import com.hxkj.config.SftpConfig;
import com.hxkj.domain.po.Companyinfo;
import com.hxkj.domain.po.Resources;
import com.hxkj.domain.po.ResourcesTree;
import com.hxkj.domain.po.Site;
import com.hxkj.service.CompanyInfoService;
import com.hxkj.service.ResourcesService;
import com.integral.mall.file.storage.sftp.SFTPStorage;
import com.platform.common.dispatcher.util.ResultStructUtils;
import com.platform.common.domain.result.ParameterDataStruct;
import com.platform.common.domain.result.ResultDataStruct;
import com.platform.common.domain.result.ResultMessageStruct;
import com.platform.common.domain.result.ResultPageStruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.Callable;

/**
 * 合作公司控制层
 * <p>
 * Created by yaosy on 2018年6月14日17:20:14
 */
@RestController
@RequestMapping("/company")
public class CompanyInfoController {

    private static final Logger LOGGER = LoggerFactory.getLogger(CompanyInfoController.class);

    @Autowired
    private CompanyInfoService companyInfoService;


    /**
     * 查询合作公司接口
     * @param parameterDataStruct
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getlist", method = RequestMethod.POST, consumes = "application/json;charset=UTF-8")
    public Callable<ResultPageStruct<Companyinfo>> getList(@RequestBody ParameterDataStruct<Companyinfo> parameterDataStruct) throws Exception {
        return () -> ResultStructUtils.buildResultPageStruct(companyInfoService.getList(parameterDataStruct.getData() == null ?
                new Companyinfo() : parameterDataStruct.getData(), parameterDataStruct.getPageTo()), "param=value");
    }

    /**
     * 新增合作公司
     *
     * @param companyinfo
     * @throws Exception
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST,consumes  ="application/json;charset=UTF-8")
    public Callable<ResultDataStruct<Companyinfo>> save(@RequestBody Companyinfo companyinfo) {
        return ()-> companyInfoService.save(companyinfo);
    }

    /**
     * 删除合作公司
     *
     *
     * @param companyinfo
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/remove",consumes  ="application/json;charset=UTF-8",method = RequestMethod.POST)
    public  Callable<ResultMessageStruct>  remove(@RequestBody Companyinfo companyinfo) {
        return ()-> companyInfoService.remove(companyinfo);
    }

    /**
     * 获取单条合作公司数据
     *
     * @param companyinfo
     * @throws Exception
     */
    @RequestMapping(value = "/get",consumes  ="application/json;charset=UTF-8",method = RequestMethod.POST)
    public  Callable<ResultDataStruct<Companyinfo>> get(@RequestBody Companyinfo companyinfo) {
        return ()-> companyInfoService.get(companyinfo);
    }

    /**
     * 修改单条合作公司数据
     * @param companyinfo
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/modify",consumes  ="application/json;charset=UTF-8",method = RequestMethod.POST)
    public  Callable<ResultMessageStruct>  modify(@RequestBody Companyinfo companyinfo)  throws Exception{
        return ()-> companyInfoService.modify(companyinfo);
    }

    /**
     * 排序
     * @param companyinfo
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/sort",consumes  ="application/json;charset=UTF-8",method = RequestMethod.POST)
    public  Callable<ResultMessageStruct>  sort(@RequestBody Companyinfo companyinfo)  throws Exception{
        return ()-> companyInfoService.sort(companyinfo);
    }


}
